package com.kuhyygy.uitl;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.ProgressDialog;
import android.util.Log;

/**
 * 活动管理器
 *     主要对应用的活动进行管理，有个最大的好处就是在退出时，可以通过此方便地把
 * 所有活动destory
 * 
 * @author acer
 *
 */
public class ActivityCollector {
	
	private static final String tag = "ActivityCollector";
	private static List<Activity> activies = new ArrayList<Activity>();

	public static void addActivity(Activity a) {
		Log.i(tag, "add activity:" + a.getClass().getSimpleName());
		activies.add(a);
	}
	
	public static void removeActivity(Activity a) {
		Log.i(tag, "remove activity:" + a.getClass().getSimpleName());
		activies.remove(a);
	}
	
	public static void removeAll() {
		for (Activity a : activies) {
			if (!a.isFinishing()) {
				a.finish();
				Log.i(tag, "destory activity:" + a.getClass().getSimpleName() );
			}
		}
	}
	
}
